<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl='http://www.w3.org/1999/XSL/Transform' version='1.0'>

	<!-- common constants template -->
	<xsl:include href="x_const.xsl"/>

	<xsl:template match="/">
		<xsl:variable name="user_name" select="$x_identity/name"/>
		<xsl:variable name="thisgrp" select="$x_identity/@group"/>
		<table width="178" border="0" cellpadding="0" cellspacing="0" class="mnu_table">
			<tr>
				<td class="mnu_menu"><p><span class="text_black">Welcome</span><br/>
				- <span class="text_red"><xsl:value-of select="$user_name"/></span><br/>
				- <span class="text_red"><xsl:call-template name="user_group"/></span></p>
				</td>
			</tr>
			<tr>
				<td class="mnu_title"><h3 align="center">Your thoughtspace</h3></td>
			</tr>
			<tr>
				<td class="mnu_menu">
					<xsl:apply-templates select="//pagemenu[(contains(@group,$thisgrp) or @group='all')]/menu[(contains(@group,$thisgrp) or @group='all')]"/>
				</td>
			</tr>
		</table>
	</xsl:template>
	
	<xsl:template match="menu">
		<p><span class="text_black"><xsl:value-of select="@label"/></span><br/>
			<xsl:apply-templates select="menuitem"/>
		</p>
		<p><xsl:call-template name="nobrspace"/></p>
	</xsl:template>
	
	<xsl:template match="menuitem">
		<xsl:variable name="thislnk" select="@lnk"/>
		<xsl:variable name="lnkgrp" select="//links/lnk[@name=$thislnk]/@group"/>
		<xsl:variable name="this_grp" select="$x_identity/@group"/>
		<xsl:if test="contains($lnkgrp,$this_grp) or $lnkgrp='all'">
			<xsl:text>- </xsl:text>
			<a class="mnu_lnk">
				<xsl:attribute name="href">
					<xsl:call-template name='url'>
						<xsl:with-param name="link"><xsl:value-of select="$thislnk"/></xsl:with-param>
					</xsl:call-template>
				</xsl:attribute>
				<xsl:value-of select="//lnk[@name=$thislnk]/menuprompt"/>
			</a><br/>
		</xsl:if>
	</xsl:template>
	
	<!-- common utilities template -->
	<xsl:include href="x_utils.xsl"/>
	<xsl:include href="x_thoughts.xsl"/>

</xsl:stylesheet>